package txAnnotation;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

@Repository("userDao")
public class UserDaoImpl implements UserDao {
	@Autowired
	private JdbcTemplate jdbcTemplate;
	public void transfer() {
		// TODO Auto-generated method stub
		String sql="update transfer set balance=balance-1000 where id=1";
		String sql2 = "update transfer set balance=balance+1000 where id=2";
		jdbcTemplate.update(sql);
		int[] i = new int[5];
		i[6]=12;
		jdbcTemplate.update(sql2);
	}
	public void transfer1() {
		String sql="update transfer set balance=balance-1000 where id=1";
		String sql2 = "update transfer set balance=balance+1000 where id=2";
		jdbcTemplate.update(sql);
		jdbcTemplate.update(sql2);
	}
	public List<User> selectAll() {
		// TODO Auto-generated method stub
		String sql = "select * from transfer";
		RowMapper<User> rowMapper = new BeanPropertyRowMapper<User>(User.class);
		List<User> list = jdbcTemplate.query(sql, rowMapper);
		return list;
	}

}
